package com.jd.basic.utils;

import lombok.Data;

/**
 * @author 小林同学
 * @version 1.0
 * @description: TODO
 * @date 2023/2/21 11:53
 */
@Data
public class AjaxResult {
    private boolean success ;
    private String msg ;
    // 上传图片需要封装额外的请求参数
    private Object resultObj;

    public static AjaxResult me(){
        return new AjaxResult();
    }

    public AjaxResult success() {
        return me().setSuccess(true).setMsg("操作成功！");
    }

    public AjaxResult success(Object obj) {
        return me().setSuccess(true).setMsg("操作成功！").setResultObj(obj);
    }
    public AjaxResult fail() {
        return me().setSuccess(false).setMsg("操作失败！");
    }

    public AjaxResult fail(String msg) {
        return me().setSuccess(false).setMsg(msg);
    }

    public AjaxResult setSuccess(Boolean success){
        this.success = success;
        return this;
    }
    public AjaxResult setResultObj(Object resultObj){
        this.resultObj = resultObj;
        return this;
    }
    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }





}
